package com.shop.web;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.shop.entity.Product;

public class ProductAction extends ActionSupport  {

	private Product  product;
	
	public String saveProduct(){
		System.out.println("-----saveProduct----");
		return SUCCESS;
	}
	public String deleteProduct(){
		
		return SUCCESS;
	}
	//问题:Action的所有业务方法都进行同样的校验
	@Override
	public void validate() {
		System.out.println("====validate====");
		if(product!=null && product.getId() ==0){
			super.addFieldError("id", "请输入商品编号");
		}
		System.out.println("name==="+product.getName()+"===");
		if( (product!=null && product.getName()==null) ||
				(product.getName()!=null && product.getName().length() ==0)  ){
			super.addFieldError("name", "请输入商品名称");
		}
		
	}
	public Product getProduct() {
		return product;
	}
	public void setProduct(Product product) {
		this.product = product;
	}
	

	
	
	
}
